package com.ly.cloud.commom.handler;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ly.cloud.vo.UserVo;
import com.ly.cloud.web.utils.WebResponse;

/**
 * 全局异常处理器，当controller出现异常的时候，会进入此类
 * @author Administrator
 *
 */
@ControllerAdvice
@ResponseBody
public class GlobalExceptionHandler {
	
	private static Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);
	
	/**
	 * 拦截所有的异常
	 * @param e
	 * @return
	 */
	@ExceptionHandler(value = Exception.class)
    public WebResponse handlerAuthorizeException(Exception e) {
        logger.debug("-------进入了全局异常处理器！-----错误信息为："+e.getMessage());
        e.printStackTrace();
        return new WebResponse<>().failure(e.getMessage());
    }
	
	

}
